<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function f1(){
            var arr=new Array();

            // console.log(typeof arr);

            arr[0]=1;
            arr[1]=2;
            arr[2]="aaa";

            console.log(arr);

            console.log(arr.length);

            arr[3]="bbb";

            console.log(arr);

            console.log(arr.length);

            for (var i = 0; i < arr.length; i++) {
                console.log(arr[i]);
            }


            var arr2=[1,2,3,"abc"];//json语法

            console.log(arr2);

            var arr3=new Array();
            arr3[0]=[1,2,3];
            arr3[1]=[4,5];

            for (var i = 0; i < arr3.length; i++) {
                for (var j = 0; j < arr3[i].length; j++) {
                    console.log(arr3[i][j]);
                }
            }


        }

        function f2(){
            var arr=[123,223,55,22,4444,222];


            console.log(arr.sort());

            var fn=function(a,b){
                return a-b;
            };


            console.log(arr.sort(fn));

            console.log(arr.sort(function(a,b){
                return a-b;
            }))

        }

        function f3(){
            var arr=[1,2,3,4,5,6,7,8,9];

            arr.forEach(function(value,index){
                console.log(value+" "+index);
            });


            var arr2=arr.filter(function(value){
                return value%2==0;
            });
            console.log(arr2);

            var arr3=arr.map(function(value){
                return value*2;
            });
            console.log(arr3)

        }

        function f4(){
            var arr=["aaa","bbb","ccc"];
            var s=arr.join("-");

            console.log(s)
        }



        function f5(){
            var stack=new Array();

            stack.push("aaa");
            stack.push("bbb");
            stack.push("ccc");
            stack.push("ddd");
            stack.push("eee");
            stack.push("fff");

            var size=stack.length;

            for (var i = 0; i < size; i++) {
                console.log(stack.pop());
            }
        }













    </script>
</head>
<body>
    <a href="javascript:;" onclick="f1();">test1</a>
    <a href="javascript:;" onclick="f2();">test2</a>
    <a href="javascript:;" onclick="f3();">test3</a>
    <a href="javascript:;" onclick="f4();">test4</a>
    <a href="javascript:;" onclick="f5();">test5</a>
</body>
</html>